home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / perl / prlbkxmp.lha / ch6 / nostrict < prev    next >
Text File  |  1991-01-08  |  1KB  |  45 lines

  1. #!/usr/bin/perl
  2.  
  3. # Usage: nostrict lint [lint_args]
  4.  
  5. # Build bit vectors with 1's for protected lines.  We use vecs
  6. # rather than normal arrays in order to save (lots of) memory.
  7.  
  8. for $arg (@ARGV) {
  9.     next unless $arg =~ /\.[ch]$/;
  10.     open(IN,$arg);
  11.     while (<IN>) {
  12.     if (m#/\*\s*NOSTRICT\s*\*/# .. m#;\s*($|/\*)#) {
  13.         vec($ok{$arg}, $., 1) = 1;
  14.     }
  15.     }
  16.     close IN;
  17. }
  18.  
  19. # Now run the command as an input pipe.
  20.  
  21. open(LINT, "-|") || exec @ARGV;
  22.  
  23. # Note that in this loop, a "next" defaults to printing the
  24. # line.  We null out $_ if we *don't* want to print it.
  25.  
  26. while (<LINT>) {
  27.     $curfile = $1 if /^(\S+\.[ch])\b/;
  28.     next unless (($file,$line) = /(\S+)\((\d+)\)/)
  29.     || ($line) = /^\s*\((\d+)\)/;
  30.     $file =~ s/\?$//;
  31.     $file = $curfile unless $file;
  32.     next unless defined $ok{$file};
  33.     $_ = '' if vec($ok{$file}, $line, 1);
  34.  
  35.     # Some lines contain two references.
  36.  
  37.     next unless ($file,$line) = /::\s*(\S+)\((\d+)\)/;
  38.     $file =~ s/\?$//;
  39.     next unless defined $ok{$file};
  40.     $_ = '' if vec($ok{$file}, $line, 1);
  41. }
  42. continue {
  43.     print;
  44. }
  45.